

const initialState = {
    token: '',
    isAuthenticated: false,
    role: '',
    fullname: '',
}

const reducer = (state = initialState, action) => {
    switch (action.type) {
        case 'SET_TOKEN':
            return {
                ...state,
                token: action.payload
            }
        case 'SET_USER_ROLE':
            return {
                ...state,
                role: action.payload 
            };
        case 'SET_FULLNAME':
            return {
                ...state,
                fullname: action.payload 
            };
        case 'CLEAR_TOKEN_AND_ROLE':
            return {
               ...initialState
            };
        case 'SET_DOCTOR_DATA':
            return {
                ...state,
                doctorData: action.payload,
            };
        case 'CLEAR_DOCTOR_DATA':
            return {
                ...state,
                doctorData: initialState.doctorData,
            };
        default:
            return state
    }
}

export default reducer;
